﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using QMERP.Domain.Entities;

namespace QMERP.Infrastructure.EFCore.Mappings
{
    public class AppMapping : IEntityTypeConfiguration<App>
    {
        public void Configure(EntityTypeBuilder<App> builder)
        {
            builder.HasQueryFilter(x => x.IsEnable);
            builder.Property(x => x.Level).IsRequired(false);
            builder.Property(x => x.PId).IsRequired(false);
            builder.Property(x => x.Type).HasMaxLength(50);
            builder.Property(x => x.Name).IsRequired(false).HasMaxLength(50);
            builder.Property(x => x.Path).IsRequired(false).HasMaxLength(500);
            builder.Property(x => x.Component).IsRequired(false).HasMaxLength(500);
            builder.Property(x => x.Redirect).IsRequired(false).HasMaxLength(500);
            builder.Property(x => x.License).HasMaxLength(200);
            builder.Property(x => x.Icon).HasMaxLength(500);
            builder.Property(x => x.Title).HasMaxLength(200);
            builder.Property(x => x.IsHide);
            builder.Property(x => x.IsKeepAlive);
            builder.Property(x => x.IsAffix);
            builder.Property(x => x.IsIframe);
            builder.Property(x => x.IsLink);
            builder.Property(x => x.Link).IsRequired(false).HasMaxLength(500);
            builder.Property(x => x.Sort).IsRequired(false);
            builder.Property(x => x.Remark).IsRequired(false).HasMaxLength(500);

            builder.HasIndex(x => x.Id);
            builder.HasIndex(x => x.Name);
            builder.HasIndex(x => x.Title);
        }
    }
}
